import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  { path: '*', redirect: '/index' } ,
  {
    path: '/seafood',
    name: 'Seafood',
    component: function(){
      return import('../views/Seafood.vue')
    },
    meta:{
      title:'生鲜小程序'
    }
  },
  {
    path: '/contact',
    name: 'Contact',
    component: function(){
      return import('../views/Contact.vue')
    },
    meta:{
      title:'联系我们'
    }
  },
  {
    path: '/service',
    name: 'Service',
    component: function(){
      return import('../views/Service.vue')
    },
    meta:{
      title:'服务项目'
    }
  },
  {
    path: '/index',
    name: 'Index',
    component: function(){
      return import('../views/Index.vue')
    },
    meta:{
      title:'首页'
    }
  },
  {
    path: '/about',
    name: 'About',
    component: function(){
      return import('../views/About.vue')
    },
    meta:{
      title:'关于我们'
    }
  },
  {
    path: '/gzxcxtop',
    name: 'Gzxcxtop',
    component: function(){
      return import('../views/Gzxcxtop.vue')
    },
    meta:{
      title:'小程序开发'
    }
  },
  {
    path: '/caseshow',
    name: 'Caseshow',
    component: function(){
      return import('../views/Caseshow.vue')
    },
    meta:{
      title:'项目展示'
    }
  },
  {
    path: '/shop',
    name: 'Shop',
    component: function(){
      return import('../views/Shop.vue')
    },
    //改名
    meta:{
      title:'商城小程序'
    }
  },
]

const router = new VueRouter({
  routes,
  // mode:'history'
})
//改名
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})
export default router
